package com.example.mobile2021606129ly0521;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import org.jetbrains.annotations.NotNull;

import java.util.List;

public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.ViewHolder>{
    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return null;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
News news=newsList.get(position);
holder.tvmainid.setText(String.valueOf(news.getId()));
holder.tvmaintitlle.setText(news.getTitle());
    }

    @Override
    public int getItemCount() {
        return newsList.size();
    }
    private List<News>newsList;
public NewsAdapter(List<News> newsList){
        this.newsList = newsList;
}
    static class ViewHolder extends RecyclerView.ViewHolder{
        TextView tvmainid,tvmaintitlle;
        public  ViewHolder(@NonNull @NotNull View itemview){
            super(itemview);
            tvmainid=itemview.findViewById(R.id.tvitemid);
            tvmaintitlle=itemview.findViewById(R.id.tvmaintitle);
        }

    }
}
